//
//  ViewFactory_obstact.m
//  工厂模式
//
//  Created by macOS on 2017/4/20.
//  Copyright © 2017年 macOS. All rights reserved.
//

#import "ViewFactory_obstact.h"
#import "WSJBtn1.h"
#import "WSJImageView.h"
#import "WSJLabel.h"

#import "FactoryParser.h"

static ViewFactory_obstact *instance = nil;

@interface ViewFactory_obstact ()

@property (nonatomic , strong) NSMutableDictionary *dict;

@end
@implementation ViewFactory_obstact


+ (instancetype)sharedInstance {
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        instance = [ViewFactory_obstact new];
    });
    return instance;
}


+ (instancetype)allocWithZone:(struct _NSZone *)zone{
    
    if (instance == nil) {
        static dispatch_once_t onceToken;
        dispatch_once(&onceToken, ^{
            instance = [ViewFactory_obstact new];
        });
    }
    
    return instance;
}


- (instancetype)init
{
    self = [super init];
    if (self) {
  
        
        //初始化  初始文件解析器
        FactoryParser *parser = [FactoryParser new];
        
        _dict = [parser  parser];
        
    }
    return self;
}

- (NSObject *)createView:(NSString *)view_type{
   
    
    //runtime 运行时读取类的属性
    return  [[NSClassFromString(_dict[view_type]) alloc] init];
    
    
}
@end
